/*    */ package com.zimbra.cs.account.accesscontrol;
/*    */ 
/*    */ import com.zimbra.common.service.ServiceException;
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ public class InlineAttrRight
/*    */   extends AttrRight
/*    */ {
/*    */   private static final String PARTS_SEPARATOR = ".";
/*    */   private static final String PARTS_SEPARATOR_ESC = "\\.";
/*    */   private static final String OP_GET = "get";
/*    */   private static final String OP_SET = "set";
/*    */   
/*    */   static InlineAttrRight newInlineAttrRight(String right)
/*    */     throws ServiceException
/*    */   {
/* 29 */     String[] parts = right.split("\\.");
/* 30 */     if (parts.length != 3) {
/* 31 */       throw ServiceException.PARSE_ERROR("inline attr right might have 3 parts", null);
/*    */     }
/*    */     Right.RightType rightType;
/* 34 */     if ("get".equals(parts[0])) {
/* 35 */       rightType = Right.RightType.getAttrs; } else { Right.RightType rightType;
/* 36 */       if ("set".equals(parts[0])) {
/* 37 */         rightType = Right.RightType.setAttrs;
/*    */       } else
/* 39 */         throw ServiceException.PARSE_ERROR("invalid op for inline attr right: " + parts[0], null); }
/*    */     Right.RightType rightType;
/* 41 */     TargetType targetType = TargetType.fromCode(parts[1]);
/* 42 */     if (targetType == TargetType.global) {
/* 43 */       throw ServiceException.PARSE_ERROR("target type for inline attr right cannot be: " + parts[1], null);
/*    */     }
/* 45 */     String attrName = parts[2];
/*    */     
/*    */ 
/* 48 */     InlineAttrRight iar = new InlineAttrRight(right, rightType);
/* 49 */     iar.setDesc(right);
/* 50 */     iar.setTargetType(targetType);
/* 51 */     iar.validateAttr(attrName);
/* 52 */     iar.addAttr(attrName);
/* 53 */     iar.completeRight();
/*    */     
/* 55 */     return iar;
/*    */   }
/*    */   
/*    */   public static String composeGetRight(TargetType targetType, String attrName) {
/* 59 */     return composeRight("get", targetType, attrName);
/*    */   }
/*    */   
/*    */   public static String composeSetRight(TargetType targetType, String attrName) {
/* 63 */     return composeRight("set", targetType, attrName);
/*    */   }
/*    */   
/*    */   private static String composeRight(String op, TargetType targetType, String attrName) {
/* 67 */     return op + "." + targetType.getCode() + "." + attrName;
/*    */   }
/*    */   
/*    */   static boolean looksLikeOne(String right) {
/* 71 */     if (right.contains(".")) {
/* 72 */       return true;
/*    */     }
/* 74 */     return false;
/*    */   }
/*    */   
/*    */   private InlineAttrRight(String name, Right.RightType rightType) throws ServiceException {
/* 78 */     super(name, rightType);
/*    */   }
/*    */   
/*    */   boolean isTheSameRight(Right other)
/*    */   {
/* 83 */     return getName().equals(other.getName());
/*    */   }
/*    */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/cs/account/accesscontrol/InlineAttrRight.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */